﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class controls_LogoutControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            try
            {
                lbProfile.Text = "Profile" + " (" + Page.User.Identity.Name + ")";
            }
            catch (Exception) { }

            liLogOn.Visible = true;            
            liLogOut.Visible = false;
            liProfile.Visible = false;
            if (Page.User.Identity.IsAuthenticated)
            {               
                liLogOn.Visible = false;
                liLogOut.Visible = true;
                liProfile.Visible = true;
            }
        }
    }

    /// <summary>
    /// Logout User
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void lbLogOut_Click(object sender, EventArgs e)
    {
        FormsAuthentication.SignOut();
        Session["UserID"] = null;
        Session["lUserName"] = "";
        FormsAuthentication.RedirectToLoginPage();
    }

    protected void lbLogOn_Click(object sender, EventArgs e)
    {
        FormsAuthentication.RedirectToLoginPage();
    }

    protected void lbProfile_Click(object sender, EventArgs e)
    {
        //Response.Redirect("~/Admin/EditUser.aspx?id=" + Session["UserID"].ToString(), false);
    }
}